﻿@model GigaSite.Web.Models.CategoriesHtmlHelperModel

@* Динамический вид с растягвающимися подкатегориями в колонки *@
@{
    // Разбираем массив категорий на столбцы
    int itemsPerFirstToRows = Model.Categories.Count % 3 != 0 ? Model.Categories.Count/2 : Model.Categories.Count /3;
    var firstRowCategories = Model.Categories.Take(itemsPerFirstToRows);
    var secondRowCategories = Model.Categories.Skip(itemsPerFirstToRows).Take(itemsPerFirstToRows);
    var thirdRowCategories = Model.Categories.Skip(itemsPerFirstToRows*2);
    ViewBag.categoryUrlFormat = Model.UrlFormat;
    ViewBag.categoryItemsCountSelector = Model.ItemsCountSelector;
}

<div class="dynamicCategories">
    <div class="firstColumn categoriesColumn">
        @foreach(var category in firstRowCategories)
        {
            @Html.Partial("DynamicCategory",category)
        }
    </div>
    <div class="secondColumn categoriesColumn">
        @foreach(var category in secondRowCategories)
        {
            @Html.Partial("DynamicCategory",category)
        }
    </div>
    <div class="thirdColumn categoriesColumn">
        @foreach(var category in thirdRowCategories)
        {
            @Html.Partial("DynamicCategory",category)
        }
    </div>
</div>
<div class="clearfix mb_40px"></div>